package com.zxy.bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 *       BeanPostProcessor。postProcessBeforeInitialization
 * 初始化 ： 对象创建完成，并赋值好调用初始化方法。。
 *      BeanPostProcessor。postProcessAfterInitialization
 */
@Component
public class MyBeanPostProcessor implements BeanPostProcessor {
    /**
     *
     * @param bean  刚创建的实例
     * @param beanName  刚创建的实例的名字
     * @return
     * @throws BeansException
     */
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("postProcessBeforeInitialization.." + beanName + " =>" + bean);
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("postProcessAfterInitialization.." + beanName + " =>" + bean);
        return bean;
    }
}
